import request from '@/utils/http'

/**
 * 库存盘点单据API服务
 * 参照原项目：RuoYi-WMS-VUE/src/api/wms/checkOrder.js
 */
export class WmsCheckOrderService {
  /**
   * 查询库存盘点单据列表
   */
  static async list(query: Record<string, any> = {}) {
    return request.get({
      url: '/wms/checkOrder/list',
      params: query
    })
  }

  /**
   * 查询库存盘点单据详细
   */
  static async detail(id: string | number) {
    return request.get({
      url: `/wms/checkOrder/${id}`
    })
  }

  /**
   * 新增库存盘点单据
   */
  static async create(data: Record<string, any>) {
    return request.post({
      url: '/wms/checkOrder',
      data
    })
  }

  /**
   * 修改库存盘点单据
   */
  static async update(data: Record<string, any>) {
    return request.put({
      url: '/wms/checkOrder',
      data
    })
  }

  /**
   * 删除库存盘点单据
   */
  static async delete(id: string | number | Array<string | number>) {
    const ids = Array.isArray(id) ? id.join(',') : id
    return request.del({
      url: `/wms/checkOrder/${ids}`
    })
  }

  /**
   * 盘库结束
   */
  static async check(data: Record<string, any>) {
    return request.post({
      url: '/wms/checkOrder/check',
      data
    })
  }

  /**
   * 导出库存盘点单据
   */
  static async export(query: Record<string, any> = {}) {
    return request.post({
      url: '/wms/checkOrder/export',
      data: query,
      responseType: 'blob'
    })
  }
}

// 为了兼容动态API系统，导出配置对象
export const checkOrderApiConfig = {
  list: '/wms/checkOrder/list',
  detail: '/wms/checkOrder',
  create: '/wms/checkOrder',
  update: '/wms/checkOrder',
  delete: '/wms/checkOrder',
  export: '/wms/checkOrder/export',
  check: '/wms/checkOrder/check'
}

export default WmsCheckOrderService
